//
//  HRUserViewModel.m
//  Hear
//
//  Created by mac on 2017/8/8.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRUserViewModel.h"

@implementation HRUserViewModel

-(void)postSaveUserRemark:(NSDictionary *)requstDict isSeccess:(void(^)(BOOL isSeccess))isSeccess{
    YTKApi *api = [YTKApi apiPostWithUrl:@"UserInfo/Post_SaveUserRemark" para:requstDict];
    [api getSuccessToken:^() {
        api.foceNoTocken = NO;
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            NSDictionary *dict = request.responseJSONObject;

            if ([dict[@"CodeStatus"] intValue] == 20000){
                isSeccess(YES);
            }else{
                isSeccess(NO);
            }
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
            isSeccess(NO);
        }];
    }];
}


-(void)getUserFollowInfo:(NSDictionary *)requstDict isSeccess:(void(^)(BOOL isSeccess))isSeccess{
    YTKApi *api = [YTKApi apiGetWithUrl:@"UserInfo/Get_GetUserFollowInfo" para:requstDict];
    [api getSuccessToken:^() {
        api.foceNoTocken = NO;
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithSuccess:^(YTKBaseRequest *request) {
            NSDictionary *dict = request.responseJSONObject;
            
            // BodyContent
            if ([dict[@"CodeStatus"] intValue] == 20000 && ![dict[@"Message"] isEqualToString:@"暂无数据"]){
                isSeccess(YES);
            }else{
                isSeccess(NO);
            }
        }];
    }];
}

-(void)getUserRelationCount:(NSDictionary *)requstDict isContentDict:(void(^)(NSDictionary* contentDict))contentDict{
    YTKApi *api = [YTKApi apiGetWithUrl:@"UserInfo/GetUserRelationCount" para:requstDict];
    [api getSuccessToken:^() {
        api.foceNoTocken = NO;
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithSuccess:^(YTKBaseRequest *request) {
            NSDictionary *dict = request.responseJSONObject;
            
            // BodyContent
            if ([dict[@"CodeStatus"] intValue] == 20000){
                contentDict([dict[@"BodyContent"] jsonValueDecoded]);
            }else{
            }
        }];
    }];
}

-(void)postSaveUserReport:(NSDictionary *)requstDict isSeccess:(void(^)(BOOL isSeccess))isSeccess{
    YTKApi *api = [YTKApi apiPostWithUrl:@"UserInfo/Post_SaveUserReport" para:requstDict];
    [api getSuccessToken:^() {
        api.foceNoTocken = NO;
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            NSDictionary *dict = request.responseJSONObject;
            
            // BodyContent
            if ([dict[@"CodeStatus"] intValue] == 20000){
                isSeccess(YES);
            }else{
                isSeccess(NO);
            }
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
            isSeccess(NO);
        }];
    }];
}


@end
